#ifndef ___MCU__UART___
#define ___MCU__UART___
#include "MCUConfig.h"

#ifdef USE_UART


/*
T2:FFFB:00\n

继电器1打开
T2:0010:00\n
继电器2打开
T2:0020:00\n
*/

// pin11,注意pin和位移关系
// S2PROTO表示S2协议，参考doc文档
#if 0
#define S2PROTO_PIN_ZERO1 (1 << 10)
#define S2PROTO_PIN_ZERO2 (1 << 11)
#define S2PROTO_PIN_FAN1 (1 << 9)
#define S2PROTO_PIN_FAN2 (1 << 8)
#define S2PROTO_PIN_HEAT1 (1 << 4)
#define S2PROTO_PIN_HEAT2 (1 << 3)
#define S2PROTO_PIN_HEAT3 (1 << 5)
#define S2PROTO_PIN_LIGHT1 (1 << 6)
#define S2PROTO_PIN_LIGHT2 (1 << 7)
#define S2PROTO_PIN_BUZ (1 << 2)
#define S2PROTO_PIN_MOTOR1HALF (1 << 1)
#define S2PROTO_PIN_MOTOR2HALF (1 << 0)
#else

#define PROTO_LEN 9


#define S2PROTO_PIN_HEAT2 (1 << 0)
#define S2PROTO_PIN_HEAT1 (1 << 1)

#define S2PROTO_PIN_FAN2 (1 << 2)
#define S2PROTO_PIN_FAN1 (1 << 3)

#define S2PROTO_PIN_LIGHT2 (1 << 4)
#define S2PROTO_PIN_LIGHT1 (1 << 5)

#define S2PROTO_PIN_MOTOR2HALF (1 << 6)
#define S2PROTO_PIN_MOTOR1HALF (1 << 7)


#define S2PROTO_PIN_BUZ (1 << 8)

#define S2PROTO_PIN_ZERO1 (1 << 10)
#define S2PROTO_PIN_ZERO2 (1 << 11)

#endif

typedef struct
{
	u8 cmd;
	u32 para;
} Cmd;
extern Cmd cmd;
char CmdSize(void);
bool CmdPushBack(Cmd cmd);
bool CmdPopFront(Cmd *cmd);
bool RxTimeOutCtrl(u8 Sel);


#if(1==MCU_CHIP_JUSHENG)
#include "JS300XUart.h"
//#define UartInit() JS300XUartInit()
//#define UartRecv() JS300XUartRecv()
//#define UartSend() JS300XUartSend()
//#define UARTSnd(cmd) JS300XUARTSnd(cmd)
#endif

extern void uart_init(void);
extern short get_tx_buf_len(void);
extern void set_tx_buf_len(u8 *buf, short len);



//end #ifdef USE_UART
#endif
#endif
